<template>
    <div>
        <Form
                :form-items="formItems"
                :submit-success="submitSuccess"
                :submit-error="submitError"
        ></Form>
        <el-form v-if="industryInfo">
            <el-form-item label="主行业编码">
                {{industryInfo.primaryIndustry}}
            </el-form-item>
            <el-form-item label="主行业名称">
                {{industryInfo.primaryIndustryName}}
            </el-form-item>
            <el-form-item label="主行业类别">
                {{industryInfo.primaryIndustryClass}}
            </el-form-item>
            <el-form-item label="主行业编码">
                {{industryInfo.secondIndustry}}
            </el-form-item>
            <el-form-item label="副行业名称">
                {{industryInfo.secondIndustryName}}
            </el-form-item>
            <el-form-item label="副行业类别">
                {{industryInfo.secondIndustryClass}}
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    import Form from '../../../../../common-util/src/components/page/Form.vue'
    export default {
        components:{
            Form
        },
        data(){
            return {
                industryInfo: null,
                formItems:[
                    {
                        field: {
                            name: 'appCode'
                        },
                        element:{
                            type: 'select',
                            select:{
                                url: this.$baseURL.wx + '/wx/mp/config/list',
                                optionProp:{
                                    value: 'appCode',
                                    label: 'appName'
                                }
                            },
                            required: true,
                            label: '公众号',
                        }
                    },

                    {
                        element:{
                            type: 'button',
                            button:[
                                {
                                    action: 'submit',
                                    requestMethod:'get',
                                    url: this.submitUrl,
                                    label: '确认获取'
                                },
                                {
                                    action: 'reset',
                                    label: '重置',
                                    type: 'default'
                                }
                            ]
                        }
                    }
                ]
            }
        },
        methods:{
            submitSuccess(res, form) {
                this.industryInfo = res
            },
            submitError(error, form) {
                if(error.response){
                    if(error.response.status == 404){
                        this.$message.error(error.response.data.msg)
                    }
                }
            },
            submitUrl(form){
                let appCode = form.appCode
                if (!appCode) {
                    return false
                }
                return this.$baseURL.wx + '/wx/mp/tempmsg/' + appCode + '/industry'
            }
        }
    }
</script>

<style scoped>

</style>